<?php

	class PlatformBase {
		static private $instance;

		static function get_instance(){/*{{{*/
			if (!self::$instance){
				self::$instance = self::init();
			}

			return self::$instance;
		}/*}}}*/

		static private function init(){/*{{{*/
			if(!($platform = SystemProperties::$platform)){
				throw new Exception("Platform is empty");
			}

			$filename = "platform_{$platform}.inc";
			if (!include($filename)){
				throw new Exception("Can't include file: $filename");
			}

			$classname = 'Platform'.ucwords($platform);
			if (!($obj = new $classname())){
				throw new Exception("Can't init class: $classname");
			}

			return $obj;
		}/*}}}*/


		function index_prepare(){/*{{{*/
		}/*}}}*/


		function html_detail_show_send_weibo($product_id){/*{{{*/
			return '';
		}/*}}}*/

		protected function html_detail_show_send_weibo_yes($product_id){/*{{{*/
			$check = $this->get_send_weibo_default($product_id);
			return sprintf('<input type="checkbox" value="1" name="check_sendweibo" id="check_sendweibo" %s /><span style="color:#695e4a">喜欢它，分享到微博</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', $check);
		}/*}}}*/

		protected function get_send_weibo_default($product_id){/*{{{*/
			$check = 'checked="checked"';
 

			if (0){
				$must_checked = array( 160, 82, ); # config-able
 
				$week_day = date("N");
				$hour = date("H");
				if (!in_array($product_id, $must_checked) && $week_day <= 5){
					if ($hour >= 9 && $hour < 18){
						$check = '';
					}
				}
			}
			 
			return $check;
		}/*}}}*/

	}
